#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
const int N = 25,mod = 998244353;
int n;
ll a[N],b[N],f[N],p[N],m,ans;
ll inv(ll x){return x==1?1:(mod-mod/x)*inv(mod%x)%mod;}
ll qp(ll x,ll y)
{
    ll s = 1;
    for(;y;y >>= 1,x = x*x%mod)
        if(y&1)s = s*x%mod;
    return s;    
}
inline ll query(ll m)
{
    if(m < 0)return 0;
    ll s = 0;
    for(int i = 1;i <= n;i++)
        (s += p[i]*qp(a[i],m)) %= mod;
    return s;
}
void dfs(int x,ll c,ll d)
{
    if(d > m)return ;
    if(x == n+1){(ans += c*query(m-d)) %= mod;return ;}
    dfs(x+1,c,d);
    dfs(x+1,(mod-c)*f[x]%mod,d+b[x]+1);
}
char buf[1<<21],*p1,*p2;
inline ll rd()
{
    char c;int f = 1;
    while(!isdigit(c = getchar()))if(c=='-')f = -1;
    ll x = c-'0';
    while(isdigit(c = getchar()))x = x*10+(c^48);
    return x*f;
}
int main()
{
    freopen("yt.in","r",stdin);
    freopen("yt.out","w",stdout);
    n = rd();m = rd();
    for(int i = 1;i <= n;i++)a[i] = rd(),b[i] = rd(),f[i] = qp(a[i],b[i]+1);
    for(int i = 1;i <= n;i++)
        for(int j = p[i] = 1;j <= n;j++)if(i != j)
            (p[i] *= inv((1-a[j]*inv(a[i])%mod+mod)%mod)) %= mod;
    dfs(1,1,0);
    cout << ans << endl;
    return 0;
}